package cn.doitedu.dwh

import org.apache.spark.sql.Row

object LogBeanUtils {

  def appLogRow2Bean1(row: Row): ApplogBean = {
    val account = row.getAs[String]("account")
    val appId = row.getAs[String]("appid")
    val appVersion = row.getAs[String]("appversion")
    val carrier = row.getAs[String]("carrier")
    val deviceId = row.getAs[String]("deviceid")
    val deviceType = row.getAs[String]("devicetype")
    val eventId = row.getAs[String]("eventid")
    val ip = row.getAs[String]("ip")
    val latitude = row.getAs[Double]("latitude")
    val longitude = row.getAs[Double]("longitude")
    val netType = row.getAs[String]("nettype")
    val osName = row.getAs[String]("osname")
    val osVersion = row.getAs[String]("osversion")
    val properties = row.getAs[Map[String, String]]("properties")
    val releaseChannel = row.getAs[String]("releasechannel")
    val resolution = row.getAs[String]("resolution")
    val sessionId = row.getAs[String]("sessionid")
    val timeStamp = row.getAs[Long]("timestamp")

    ApplogBean(
      account,
      appId,
      appVersion,
      carrier,
      deviceId,
      deviceType,
      eventId,
      ip,
      latitude,
      longitude,
      netType,
      osName,
      osVersion,
      properties,
      releaseChannel,
      resolution,
      sessionId,
      timeStamp
    )
  }



  def appLogRow2Bean2(row: Row): ApplogBean = {
    val account = row.getAs[String]("account")
    val appId = row.getAs[String]("appId")
    val appVersion = row.getAs[String]("appVersion")
    val carrier = row.getAs[String]("carrier")
    val deviceId = row.getAs[String]("deviceId")
    val deviceType = row.getAs[String]("deviceType")
    val eventId = row.getAs[String]("eventId")
    val ip = row.getAs[String]("ip")
    val latitude = row.getAs[Double]("latitude")
    val longitude = row.getAs[Double]("longitude")
    val netType = row.getAs[String]("netType")
    val osName = row.getAs[String]("osName")
    val osVersion = row.getAs[String]("osVersion")
    val properties = row.getAs[Map[String, String]]("properties")
    val releaseChannel = row.getAs[String]("releaseChannel")
    val resolution = row.getAs[String]("resolution")
    val sessionId = row.getAs[String]("sessionId")
    val timeStamp = row.getAs[Long]("timeStamp")
    val newsession = row.getAs[String]("newsession")
    val country = row.getAs[String]("country")
    val province = row.getAs[String]("province")
    val city = row.getAs[String]("city")
    val region = row.getAs[String]("region")
    val bindAccount = row.getAs[String]("bindAccount")
    val isnew = row.getAs[Int]("isnew")
    val guid = row.getAs[Long]("guid")
    val dt = row.getAs[String]("dt")

    ApplogBean(
      account,
      appId,
      appVersion,
      carrier,
      deviceId,
      deviceType,
      eventId,
      ip,
      latitude,
      longitude,
      netType,
      osName,
      osVersion,
      properties,
      releaseChannel,
      resolution,
      sessionId,
      timeStamp,
      newsession,
      country,
      province,
      city,
      region,
      bindAccount,
      isnew,
      guid,
      dt
    )
  }



}
